/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * StartupPanel.java
 *
 * Created on May 18, 2009, 11:40:08 AM
 */

package GUI;

import OverlayNetwork.jxtaPeerSetup;

/**
 *
 * @author cs47402_08
 */
public class StartupPanel extends javax.swing.JPanel {

    /** Creates new form StartupPanel */
    public StartupPanel() {
        initComponents();
    }

    public static boolean checkID(){
        if(peerIdTextBox.getText().equals("changeMe")){
            return false;
        }
        else{
            return true;
        }
    }

    public static boolean checkPipe() {
        if(pipeIdTextBox.getText().equals("defaultPipe")){
            return false;
        }
        else{
            return true;
        }
    }

    public static boolean checkRendStatus(){
        if(rendNodeCheck.isSelected()){
            return true;
        }
        else{
            return false;
        }
    }

    public static String getPipeID() {
        return pipeIdTextBox.getText();
    }

    public static String getPeerID(){
        return peerIdTextBox.getText();
    }

    public static String getGroupID(){
        return groupIdTextBox.getText();
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        rendNodeCheck = new javax.swing.JCheckBox();
        sendDiscoveryButton = new javax.swing.JButton();
        groupIdTextBox = new javax.swing.JTextField();
        groupLabel = new javax.swing.JLabel();
        peerIdTextBox = new javax.swing.JTextField();
        peerIdLabel = new javax.swing.JLabel();
        pipeIdLabel = new javax.swing.JLabel();
        pipeIdTextBox = new javax.swing.JTextField();
        startJxtaButton = new javax.swing.JButton();
        stopJXTAButton = new javax.swing.JButton();

        setMaximumSize(new java.awt.Dimension(33, 80));
        setMinimumSize(new java.awt.Dimension(33, 80));
        setPreferredSize(new java.awt.Dimension(470, 300));

        jLabel1.setFont(new java.awt.Font("Lucida Bright", 0, 18));
        jLabel1.setText("JXTA Configuration");

        rendNodeCheck.setText("Rendezvous Node");

        sendDiscoveryButton.setText("Send Discovery");

        groupIdTextBox.setText("group");
        groupIdTextBox.setToolTipText("Advanced users can enter a group name to become part of here");

        groupLabel.setText("Default Group: ");

        peerIdTextBox.setText("changeMe");
        peerIdTextBox.setToolTipText("User selected peer id");

        peerIdLabel.setText("Peer ID:");

        pipeIdLabel.setText("Pipe ID:");

        pipeIdTextBox.setText("defaultPipe");

        startJxtaButton.setText("Start JXTA Sharing");
        startJxtaButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startJxtaButtonActionPerformed(evt);
            }
        });

        stopJXTAButton.setText("Stop JXTA Network");
        stopJXTAButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                stopJXTAButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addContainerGap(288, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(rendNodeCheck)
                        .addContainerGap(347, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(peerIdTextBox, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
                        .addGap(347, 347, 347))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(peerIdLabel)
                        .addContainerGap(420, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(pipeIdLabel)
                        .addContainerGap(422, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(pipeIdTextBox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
                            .addComponent(groupIdTextBox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                .addComponent(groupLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 39, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(347, 347, 347))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(startJxtaButton)
                        .addGap(18, 18, 18)
                        .addComponent(stopJXTAButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 77, Short.MAX_VALUE)
                        .addComponent(sendDiscoveryButton)
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addComponent(rendNodeCheck)
                .addGap(18, 18, 18)
                .addComponent(peerIdLabel)
                .addGap(5, 5, 5)
                .addComponent(peerIdTextBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(groupLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(groupIdTextBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pipeIdLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(pipeIdTextBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sendDiscoveryButton)
                    .addComponent(startJxtaButton)
                    .addComponent(stopJXTAButton))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void startJxtaButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_startJxtaButtonActionPerformed
        jxtaPeerSetup.startUp();
    }//GEN-LAST:event_startJxtaButtonActionPerformed

    private void stopJXTAButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_stopJXTAButtonActionPerformed
        jxtaPeerSetup.shutDown();
    }//GEN-LAST:event_stopJXTAButtonActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private static javax.swing.JTextField groupIdTextBox;
    private javax.swing.JLabel groupLabel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel peerIdLabel;
    private static javax.swing.JTextField peerIdTextBox;
    private javax.swing.JLabel pipeIdLabel;
    private static javax.swing.JTextField pipeIdTextBox;
    private static javax.swing.JCheckBox rendNodeCheck;
    private javax.swing.JButton sendDiscoveryButton;
    private javax.swing.JButton startJxtaButton;
    private javax.swing.JButton stopJXTAButton;
    // End of variables declaration//GEN-END:variables

}
